package net.joyphper.service.impl;

import java.util.Date;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.joyphper.bean.User;
import net.joyphper.commons.exception.AppTranException;
import net.joyphper.mapper.UserMapper;
import net.joyphper.service.UserService;

@Transactional
@Service("userService")
public class UserServiceImpl implements UserService {
	@Autowired
	private UserMapper userMapper;

	@Override
	public User getUserByLoginMail(String loginMail) {
		return this.userMapper.getUserByLoginMail(loginMail);
	}
	
	@Override
	public User getUserById(long id) {
		return this.userMapper.getUserById(id);
	}
	
	@Override
	public void updateLoginTime(Date time, long id) throws AppTranException {
		this.userMapper.updateLoginTime(time, id);
	}

	@Override
	public void updatePwd(String pwd, long id) throws AppTranException {
		this.userMapper.updatePwd(pwd, id);
	}
	
	
	@Override
	public Set<Long> getRolesIdByUserId(Long userId) {
		return this.userMapper.getRolesIdByUserId(userId);
	}

	@Override
	public Set<String> getResourcesIdByUserId(Long userId) {
		return this.userMapper.getResourcesIdByUserId(userId);
	}
	
}

